import requests


class HtmlDownloader:
    def download(self, url):
        """
        下载 html 页面源码
        :param url: url
        :return: str / None
        """
        if not url:
            return None

        headers = {
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:63.0) Gecko/20100101 Firefox/63.0',
        }
        r = requests.get(url, headers=headers)
        if r.status_code == 200:
            r.encoding = 'utf-8'
            return r.text
        else:
            return None